---
id: "pipe"
keywords: ["pipe", "operator", "function", "argument"]
name: "->"
summary: "This is the `pipe` operator."
category: "operators"
---

The `->` operator passes a value into the first argument position of a function. Typically it's used to chain multiple function calls together in a "pipeline like" fashion.

### Example

<CodeTab labels={["ReScript", "JS Output"]}>

```res
let dieRoll = size => {
  Math.Int.random(1, size)
}

let dieRollMessage = (value, name) => {
  "Hi " ++ name ++ ", you rolled a " ++ Int.toString(value)
}

let message = dieRoll(6)->dieRollMessage("Marshall")
```

```js
function dieRoll(size) {
  return Core__Math.Int.random(1, size);
}

function dieRollMessage(value, name) {
  return "Hi " + name + ", you rolled a " + value.toString();
}

var message = dieRollMessage(dieRoll(6), "Marshall");
```

</CodeTab>

Which produces a message such as `Hello Marshall, you rolled a 3`.

You can also explicitly define the argument position of a piped value by using the `_` placeholder:

<CodeTab labels={["ReScript", "JS Output"]}>

```res example
let logMsg = (user: string, datestr: string, msg: string): unit => {
  Console.log(`${user}|${datestr}|${msg}`)
}

let datestr = "01-01-2021"
let user = "admin"

// Here, we put the result of toUpperCase into the last position
// denoted with an _
String.toUpperCase("example message")->logMsg(user, datestr, _)
```

```js
function logMsg(user, datestr, msg) {
  console.log(user + "|" + datestr + "|" + msg);
}

var datestr = "01-01-2021";

var user = "admin";

(function (__x) {
  logMsg(user, datestr, __x);
})("example message".toUpperCase());
```

</CodeTab>

### References

- [Pipe](../docs/manual/pipe.mdx)
